package com.gc.services.impl;

import com.gc.dao.custom.DeviceMapper;
import com.gc.dao.custom.DeviceRecordMapper;
import com.gc.dao.custom.DeviceUseMapper;
import com.gc.pojo.SysDevice;
import com.gc.pojo.SysDeviceRecord;
import com.gc.pojo.SysDeviceUse;
import com.gc.services.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private DeviceUseMapper deviceUseMapper;

    @Override
    public List<SysDevice> getAllDevice() {
        return deviceMapper.selectAllDevice();
    }

    @Override
    public SysDevice getDeviceByNumber(String number) {
        return deviceMapper.selectByNumber(number);
    }

    @Override
    public int addDevice(SysDevice device) {
        return deviceMapper.insertSelective(device);
    }

    @Override
    public int addDeviceUse(SysDeviceUse use) {
        return deviceUseMapper.insertSelective(use);
    }

    @Override
    public int remove(Integer deviceId) {
        return deviceMapper.deleteByPrimaryKey(deviceId);
    }

    @Override
    public SysDevice getDeviceById(Integer deviceId) {
       return  deviceMapper.selectByPrimaryKey(deviceId);
    }

    @Override
    public int modifyDevice(SysDevice device) {
        return deviceMapper.updateByPrimaryKeySelective(device);
    }
}
